﻿using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Tpl.Domain.Entities;

namespace Tpl.Domain.Config
{
    public class RegistrationDetailConfig : EntityTypeConfiguration<RegistrationDetail, long>
    {
        public override void Configure(EntityTypeBuilder<RegistrationDetail> builder)
        {
            base.Configure(builder);

            builder.Property(x => x.Id).ValueGeneratedOnAdd(); 
            builder.HasOne(r => r.Registration).WithMany(x => x.Details)
                .HasForeignKey(r => r.RegistrationId).IsRequired(false);
            builder.HasOne(r => r.Book);
        }
    }
}